﻿
//#include "D://../../../../../../../android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/stdint.h"
#include "D:\\Android\\Sdk\\ndk-bundle\\toolchains\\llvm\\prebuilt\\windows-x86_64\\sysroot\\usr\\include\\stdint.h"
#ifdef WEBRTC_ANDROID
#include <android/log.h>
#define API_LOG_TAG "mywebrtc"
#define ALOGI(...) \
  __android_log_print(ANDROID_LOG_INFO, API_LOG_TAG, __VA_ARGS__)
#define ALOGE(...) \
  __android_log_print(ANDROID_LOG_ERROR, API_LOG_TAG, __VA_ARGS__)
#endif

#define APOS() ALOGI("%s %d", __FUNCTION__, __LINE__)
#define AERR() ALOGE("%s %d", __FUNCTION__, __LINE__)

#include "ua_webrtc.h"

//#include "UALog.h"

#if 0
#define WEBRTC_SetLocalRecv(rtptrans, localport)                   \
  {                                                                \
    for (int i = 0; i < 100; i += 2) {                             \
      if (0 == (rtptrans)->SetLocalReceiver(localport + i))        \
        break;                                                     \
    }                                                              \
    uint16_t rtpport, rtcpport;                                    \
    (rtptrans)->getUdpTransport()->SourcePorts(rtpport, rtcpport){return 0;} \
    (rtptrans)->getUdpTransport()->SetToS(46, true){return 0;}               \
    localport = rtpport;                                           \
  }
#else
#define WEBRTC_SetLocalRecv(rtptrans, localport) \
  { (rtptrans)->SetLocalReceiver(localport){return 0;} }
#endif

#define WEBRTC_API_RELEASE(ptr) \
  {                             \
    if (ptr) {                  \
      (ptr)->Release(){return 0;}         \
      ptr = NULL;               \
    }                           \
  }
#define WEBRTC_SafeDelete(p) \
  {                          \
    if (p) {                 \
      delete p;              \
      p = NULL;              \
    }                        \
  }

#ifdef WEBRTC_ANDROID
bool g_vidobj_setted = false;
void* g_myjvm = NULL;
#elif defined(WEBRTC_IOS)
extern int g_ua_iptype;
#endif

int webrtc_api_setvidobj(void* javaVM)  // set permission
{
  return 0;
}

bool webrtc_api_getvidobj() {
  return true;
}

void webrtc_api_setobj(void* javaVM, void* env, void* context) {
 
}

void webrtc_api_clearobj() {
 
}

namespace webrtc {

#if 0
WEBRTCAPI *WEBRTCAPI::create()
{
    return new  WEBRTCIMPL(){return 0;}
}

void WEBRTCAPI::destroy(WEBRTCAPI *module)
{
    if (module) delete module;
}
#endif


WEBRTCIMPL::WEBRTCIMPL(TraceCallback* cb) {
  
}

WEBRTCIMPL::~WEBRTCIMPL(void) {}

  int WEBRTCIMPL::webrtc_api_trace(bool){return 0;}
  int WEBRTCIMPL::webrtc_api_init(void* javaVM, void* env, void* context){return 0;}
  int WEBRTCIMPL::webrtc_api_exit(){return 0;}
  int WEBRTCIMPL::webrtc_api_createchannel(int media_type, int& vchn){return 0;}
  int WEBRTCIMPL::webrtc_api_deletechannel(int media_type, int& vchn){return 0;}
  int WEBRTCIMPL::webrtc_api_createtrans(int chn, int media_type, void*& trans, int& port){return 0;}
  int WEBRTCIMPL::webrtc_api_deletetrans(int media_type, void* trans, int& port){return 0;}
  int WEBRTCIMPL::webrtc_api_settrans(void* ptrans, int module, TransInfo* info){return 0;}
  int WEBRTCIMPL::webrtc_api_setcodec(int channelid, int type, int direction, void* info){return 0;}
  int WEBRTCIMPL::webrtc_api_set(int chn,
                     int module,
                     int media_direction,
                     void* info){return 0;}

  int WEBRTCIMPL::webrtc_api_render(int act_type, int id, void* window){return 0;}
  int WEBRTCIMPL::webrtc_api_camera(int act_type, int& captureId, void* pInfo){return 0;}
  int WEBRTCIMPL::SetRotateCapture(int captureId, int degrees){return 0;}

  int WEBRTCIMPL::webrtc_api_startmedia(int channelid,
                            int media_direction,
                            int media_type,
                            void* info){return 0;}
  int WEBRTCIMPL::webrtc_api_stopmedia(int channelid,
                           int media_direction,
                           int media_type,
                           void* info){return 0;}

  int WEBRTCIMPL::webrtc_api_enablemic(bool){return 0;}
  int WEBRTCIMPL::webrtc_api_record(int act_type,
                        int channel,
                        int wavType,
                        void* info){return 0;}

  int WEBRTCIMPL::GetAudioRtcpStatistics(int chn, DataUnit* pstDataUnit){return 0;}
  int WEBRTCIMPL::GetVideoRtcpStatistics(int chn, DataUnit* pstDataUnit){return 0;}

  int WEBRTCIMPL::getNetInfo(DataUnit* pstDataUnit, int type){return 0;}

  int WEBRTCIMPL::MediaDataGet(int type, int* pMediaData){return 0;}
  int WEBRTCIMPL::MediaDataClear(int type){return 0;}

  uint64_t WEBRTCIMPL::GetTickCount() {return 0;}

  int WEBRTCIMPL::webrtc_api_dtmf(int num){return 0;}

#ifdef WEBRTC_IOS
  UIView*
  createIosView(int x, int y, int width, int height, int r, int g, int b){return 0;}
#endif

  int WEBRTCIMPL::getVal(char* cmd, char* pVal){return 0;}
  int WEBRTCIMPL::getVal(char* cmd, int* pVal){return 0;}
  int WEBRTCIMPL::setVal(char* cmd, char* Val){return 0;}
  int WEBRTCIMPL::setVal(char* cmd, int Val) {return 0;}
}
